#ifndef RESULTDEGREE_H
#define RESULTDEGREE_H

#include <QtCore/QVector>
#include <QtCore/QMap>

#include <ed_core/global/enum.h>
#include <ed_core/global/defs.h>

namespace ed_core
{

class ED_CORE_API ResultDegree
{
public:
  /**
   * @return The global instance of the Degree object.
   */
  static ResultDegree* inst();

  /**
   * @brief The Degree enum describes a result degree as specified by the Result degree table (RdJ p. 20).
   */
  ENUM(Degree,
    Undefined,
    Pathetic,
    Mediocre,
    Average,
    Good,
    Excellent,
    Extraordinary);

  /**
   * @brief checks the result degree of a test by comparing the result obtained to the test's difficulty
   * This method is based on the Result degree table (RdJ p.20) values.
   * @param result The result obtained with the dice roll.
   * @param difficulty The base difficulty defined for the test.
   * @return The result degree obtained.
   * @see The Degree enum for possible values.
   */
  Degree check(quint32 result, quint32 difficulty);

private:
  static ResultDegree* _instance;

  // Maps each degree to the minimum result nedded to obtain it.
  typedef QMap<Degree,quint32> DegreeResultMap;
  // Maps each difficulty to the values needed for each degree
  QVector<DegreeResultMap> _resultDegrees;

  ResultDegree();
  void initResultDegreeMap();
};

} // namespace ed_core

#endif // RESULTDEGREE_H
